﻿Imports System.Data
Imports VSModel
Imports Cls_Common
Imports SecurityService

Partial Class Control_MSDS_Section02View
	Inherits System.Web.UI.UserControl
	Private Shared ReadOnly log As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
#Region "Sub and Function "
	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		If Not IsPostBack Then
			Translate()
			Me.EnableViewState = False
			Dim script As ScriptManager = ScriptManager.GetCurrent(Me.Page)
			If Not script Is Nothing AndAlso script.IsInAsyncPostBack Then
				ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "duyjs", "ajaxJquery()", True)
			Else
				Me.Page.ClientScript.RegisterStartupScript(Me.Page.GetType(), "duyjs", String.Concat("Sys.Application.add_load(function(){", "ajaxJquery()", "});"), True)
			End If
			If Not Request.QueryString("Id").ToString.Equals("0") Then
				hidMSDSID.Value = Request.QueryString("Id")
			End If
			CheckData()
		End If
	End Sub
	Protected Sub Translate()
		lblHeaderNhandang.Text = getTranslate("lblHeaderNhandang", Session("LanguageId"), lblHeaderNhandang.Text)
		lblHeaderThanhphan02.Text = getTranslate("lblHeaderThanhphan02", Session("LanguageId"), lblHeaderThanhphan02.Text)
		lblHeaderSoCAS02.Text = getTranslate("lblHeaderSoCAS02", Session("LanguageId"), lblHeaderSoCAS02.Text)
		lblHeaderCTHH02.Text = getTranslate("lblHeaderCTHH02", Session("LanguageId"), lblHeaderCTHH02.Text)
		lblHeaderPhantram02.Text = getTranslate("lblHeaderPhantram02", Session("LanguageId"), lblHeaderPhantram02.Text)
		
	End Sub

	Sub CheckData()
		Using data As New VSEntities
			Dim LanguageId = Session("LanguageId").ToString()
			Dim p = (From q In data.MSDSSection02
			   Where q.LanguageId = LanguageId And q.MSDSId = hidMSDSID.Value
			   ).FirstOrDefault()
            If Not p Is Nothing Then
                txtS210.Text = p.S210
                txtS220.Text = p.S220
                txtS230.Text = p.S230
                txtS240.Text = p.S240
                txtS250.Text = p.S250
                txtS211.Text = p.S211
                txtS212.Text = p.S212
                txtS213.Text = p.S213
                txtS221.Text = p.S221
                txtS222.Text = p.S222
                txtS223.Text = p.S223
                txtS231.Text = p.S231
                txtS232.Text = p.S232
                txtS233.Text = p.S233
                txtS241.Text = p.S241
                txtS242.Text = p.S242
                txtS243.Text = p.S243
                txtS251.Text = p.S251
                txtS252.Text = p.S252
                txtS253.Text = p.S253
            End If
		End Using
	End Sub
#End Region

End Class
